#!/usr/bin/python
# -*- coding: utf-8 -*-
#coding=utf-8
import datetimeDemo as tsLog
def demo():
    tsLog.logTs("dicDemo", preNewLineNum=2)
    monthDic = {
        "January": 31,
        "February": 28,
        "March": 31,
        "April": 30,
        "May": 31,
        "June": 30,
        "July": 31,
        "August": 31,
        "September": 30,
        "October": 31,
        "November": 30,
        "December": 31}

    # 直接打印输出 整体，键，值
    print(monthDic)
    print(monthDic.keys())
    print(monthDic.values())

    # 遍历
    for key in monthDic:
        print(key, monthDic[key])
    for key, val in monthDic.items():
        print(key, val)

    # key 存在测试
    if "Test" in monthDic:
        del monthDic["Test"]
    else:
        monthDic["Test"] = 3.14
    print(monthDic)

    # key 排序，遍历
    for key in sorted(monthDic.keys()):
        print("sorted : ", key, monthDic[key])
    for key in sorted(monthDic.keys(), key=lambda x:len(x)):
        print("key len sorted: ", key, monthDic[key])



if __name__ == '__main__':
    demo()